#
# Makefile for the ProTcl. It has been tried only on
# a Sun Sparc running SunOS 3.1 and only with SICStus 2.1 and ECLiPSe 3.4
#
# sccsid("@(#)makefile	1.4          93/12/16").
# sccscr("@(#)  Copyright 1993 ECRC GmbH ").
#

all: tksicstus

CC=gcc
# Modify these values for your installation

# The directory with the Tcl/Tk installation
TK	= /usr/local/

# The Tk source directory
TK_SOURCE = /usr/local/lib/tk

# The ProTcl source directory
PROTCL_SOURCE = /usr/local/lib/tk

# X include directory
X_INC_DIR =/usr/local/X11R5/include

# ECLiPSe include directory
ECLIPSE_INCLUDE = /usr/local/eclipse/include

# SICStus include directory
SICSTUS_INCLUDE = /usr/local/sicstus2.1
SP = $(SICSTUS_INCLUDE)

# Quintus include directory
QUINTUS_INCLUDE = .

# Define TK_TEST if you want to run all Tk test programs
OPT	= -O -DTK_TEST

eclipse:	tk.c dirs.pl
		$(CC) $(OPT) -c -Bstatic -I$(TK)/include -I$(X_INC_DIR) \
			-DECLIPSE -I$(ECLIPSE_INCLUDE) tk.c
		/bin/cp etk.pl tk.pl

sicstus:	tk.c dirs.pl
		$(CC) $(OPT) -c -I$(TK)/include -I$(X_INC_DIR) \
			-DSICSTUS -I$(SICSTUS_INCLUDE) tk.c
		/bin/cp stk.pl tk.pl
		
quintus:	tk.c dirs.pl
		$(CC) $(OPT) -c -I$(TK)/include -I$(X_INC_DIR) \
			-DQUINTUS -I$(QUINTUS_INCLUDE) tk.c
		/bin/cp qtk.pl tk.pl
		
dirs.pl:
		echo "tk_installation('$(TK)')." > dirs.pl
		echo "tk_source('$(TK_SOURCE)')." >> dirs.pl
		echo "protcl_source('$(PROTCL_SOURCE)')." >> dirs.pl


COMPILING=fastcode
install-static: static
	cp static /usr/local/bin/tksicstus
tksicstus: sptcl
	echo "use_module(library(tk)),"\
	'save_program(tksicstus).' | SP_PATH=$(SP) \
	./sptcl -f -b $(SP)/Library/boot.ql
sptcl :tk.o flinkage.o
	$(CC) -o sptcl $(SP)/Emulator/sp.o  \
	tk.o flinkage.o -L/usr/local/X11R5/lib -ltk -ltcl -lX11 -lm
flinkage.c: tk.o stforeign.pl
	echo "[stforeign],halt." | sicstus
flinkage.o: flinkage.c
	$(CC) -O -c -I$(SP)/Runtime flinkage.c
tk.o: tk.c
	$(CC) $(OPT) -c -I$(TK)/include -I$(X_INC_DIR) \
			-DSICSTUS -I$(SICSTUS_INCLUDE) tk.c
